package com.dyz.wsw.front.market.controller;

import com.dyz.wsw.common.web.JsonResult;
import com.dyz.wsw.front.market.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

/**
 * @author dyz
 * @date 2025/1/15 15:20
 */
@RestController
@RequestMapping("/category")
@Slf4j
public class CategoryController {

    private final CategoryService categoryService;


    public CategoryController(CategoryService categoryService) {
        log.debug("创建控制器对象: CategoryController");
        this.categoryService = categoryService;
    }


    @GetMapping("/all")
    public Mono<JsonResult> getAllCategory(){
        return categoryService.findAllCategory()
                .collectList()
                .map(JsonResult::ok);
    }

}
